/*
PearReview - The peer review assistant.
Copyright (C) 2009  Dimitrij Pankratz, Anton Musichin
http://www.pearreview.com, info@pearreview.com

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

package com.pearreview.ui;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;

import javax.swing.JPanel;

public class StepTabPanel extends JPanel {
	private static final long serialVersionUID = -9061074482341779656L;
	private boolean selected = false;
	private boolean first = false;

	public StepTabPanel() {
		super();
	}
	
	public boolean isSelected() {
		return selected;
	}
	
	public void setSelected(boolean selected) {
		this.selected = selected;
	}
	
	public void setFirst(boolean first) {
		this.first = first;
	}
	
	public boolean isFirst() {
		return first;
	}
	
	@Override
	protected void paintComponent(Graphics g) {
		Graphics2D g2 = (Graphics2D) g;
		super.paintComponent(g);
		GradientPaint p;
		Paint oldPaint;
		if (selected) {
			p = new GradientPaint(0, 0, new Color(0x939393),
					0, getHeight(), new Color(0xc9c9c9));
					oldPaint = g2.getPaint();
					g2.setPaint(p);
					g2.fillRect(0, 0, getWidth(), getHeight());
					
					g2.setPaint(p);
					g2.fillRect(0, 0, getWidth(), getHeight());
					
					g2.setColor(new Color(0xd5d5d5));
					g2.drawRect(0, getHeight()-2, getWidth(), 1);
		} else {
			p = new GradientPaint(0, 0, new Color(0x919193),
					0, getHeight(), new Color(0x808080));
					oldPaint = g2.getPaint();
					g2.setPaint(p);
					g2.fillRect(0, 0, getWidth(), getHeight());
					
					g2.setPaint(p);
					g2.fillRect(0, 0, getWidth(), getHeight());
					
					g2.setColor(new Color(0x999999));
					g2.drawRect(0, getHeight()-2, getWidth(), 1);
		}
		
		g2.setColor(new Color(0x666666));
		g2.drawRect(0, getHeight()-1, getWidth(), 1);
		
		if (first) {
			//g2.setColor(new Color(0x666666));
			g2.drawRect(0, -1, getWidth(), 1);
		}
		
		g2.setPaint(oldPaint);
	}
}